package com.fortune.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.fortune.dto.in.dRole.DRoleAddDto;
import com.fortune.dto.in.dRole.DRoleEditDto;
import com.fortune.dto.in.dRole.DRoleListDto;
import com.fortune.dto.in.dRole.PermissionAddDto;
import com.fortune.entity.DPosition;
import com.fortune.vo.dRole.DRoleB;
import com.fortune.vo.dRole.PermissionInDRole;

/**
 * 
 * @author ran
 *
 */
public interface DRoleDao {
	/**
	 * 
	 * @param listDto
	 * @param mId
	 * @param dId
	 * @return
	 */
	List<DRoleB> listRoles(@Param("dto") DRoleListDto listDto, @Param("dId") String dId);
	/**
	 * 
	 * @param listDto
	 * @param mId
	 * @param dId
	 * @return
	 */
	int countRoles(@Param("dto") DRoleListDto listDto, @Param("dId") String dId);
	/**
	 * 
	 * @param mId
	 * @param dId
	 * @param roleId
	 * @return
	 */
	DPosition getPositionByMIdAndDIdAndRoleId(@Param("dId") String dId, @Param("roleId") String roleId);
	/**
	 * 
	 * @return
	 */
	List<PermissionInDRole> listPermissions();
	/**
	 * 
	 * @param mId
	 * @param dId
	 * @param roleId
	 * @return
	 */
	List<String> getPermissionIdsByRole(@Param("dId") String dId, @Param("roleId") String roleId);
	/**
	 * 
	 * @param name
	 * @param mId
	 * @param dId
	 * @return
	 */
	DPosition getPositionByMIdAndDIdAndName(@Param("name") String name, @Param("dId") String dId);
	/**
	 * 
	 * @param addDto
	 * @param mId
	 * @param dId
	 * @param roleId
	 * @return
	 */
	int insertRole(@Param("dto") DRoleAddDto addDto,@Param("dId") String dId, @Param("roleId") String roleId);
	/**
	 * 
	 * @param permissions
	 * @return
	 */
	int countExsistPermissionCount(@Param("list") List<PermissionAddDto> permissions);
	/**
	 * 
	 * @param permissions
	 * @param mId
	 * @param dId
	 * @param roleId
	 * @return
	 */
	int insertRolePermissions(@Param("permissions") List<PermissionAddDto> permissions, @Param("dId") String dId, @Param("roleId") String roleId);
	/**
	 * 
	 * @param name
	 * @param mId
	 * @param dId
	 * @param roleId
	 * @return
	 */
	DPosition getPositionByMIdAndDIdAndNameAndRoleId(@Param("name") String name, @Param("dId") String dId, @Param("roleId") String roleId);
	/**
	 * 
	 * @param editDto
	 * @param mId
	 * @param dId
	 * @return
	 */
	int updateRole(@Param("dto") DRoleEditDto editDto,@Param("dId") String dId);
	/**
	 * 
	 * @param roleId
	 * @param mId
	 * @param dId
	 */
	void deletePermissionsByRoleId(@Param("roleId")String roleId, @Param("dId") String dId);
	/**
	 * 
	 * @param mId
	 * @param dId
	 * @param roleId
	 * @return
	 */
	int deleteRole(@Param("dId") String dId, @Param("roleId") String roleId);

	int findEvery(@Param("did")String did,@Param("roleId")String roleId);
}
